<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/common.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../css/templet.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../fonts/font-awesome.min.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../mui/css/mui.css?01_38" />

		<!--公共js-->
		<script type="text/javascript" src="../common/js/jquery.js?01_38"></script>

		<!--插件-->
		<script type="text/javascript" src="../common/js/vue.min.js?01_38"></script>
		<script type="text/javascript" src="../common/js/mui.min.js?01_38"></script>

		<script type="text/javascript" src="../common/js/fastclick.js"></script>
		<script type="text/javascript" src="../common/js/common.js?01_38"></script>
		<script type="text/javascript" src="../common/js/my_common.js?01_38"></script>
		<script type="text/javascript" src="../common/js/main.js?01_38"></script>
		<script type="text/javascript" src="../common/js/app.js?01_38"></script>
	</head>

	<body>
		<header class="bg-red9 fff f-20 pad-t-10 pad-b-25 pad-l-10 pad-r-10">
			<div class="pa back" onclick="cli_backpre()">
				<a></a>
			</div>
			<div class="center"><span data-l="1363"></span> / <span data-l="1364"></span></div>
			<div class="pa see f-12">
				<a onclick="clicked('writeOffRecord.html')" class="fff"></a>
			</div>
		</header>
		<div id="app" v-cloak>
			<div class="wrap_body vip_card_alter">

				<div class="content pad-t-45">
					<div>
						<div class="list pad-l-12 pad-r-12">
							<p class="fiex pad-t-15"><span class="bg bg_01"></span> <span class="pad-l-10">{{b_lg[1363]}}</span>
								<spann class="pad-l-10">{{point}}</span>
							</p>
							<div class="fiex pad-t-10 pad-b-10 inp active" @click="num(1,$event)">
								<div class="alter center pr f-24" @click="alter">
									<span class="sign" v-if="add == 1">+</span>
									<span class="sign" v-else="">-</span>
									<span class="bg_pull" style="position: absolute; top: 18px; right: 9px;"></span>
								</div>
								<div class="fiex1 inps"><input type="text" name="" id="" value="" disabled placeholder="0" class="col-sm-11 pad-l-20 f-24" v-model="gold" /></div>
							</div>
						</div>
						<div class="list pad-l-12 pad-r-12">
							<p class="fiex pad-t-15"><span class="bg bg_02"></span> <span class="pad-l-10">{{b_lg[1394]}}</span>
								<spann class="pad-l-10">{{amount}}</span>
							</p>
							<div class="fiex pad-t-10 pad-b-10 inp" @click="num(2,$event)">
								<div class="alter center f-24 ">-</div>
								<div class="fiex1 inps"><input type="text" name="" id="" value="" disabled placeholder="0" class="col-sm-11 pad-l-20 f-24" v-model="balance" /></div>
							</div>
						</div>
					</div>
					<p class="pad-l-12 pad-r-12 pad-t-10 f-12">{{b_lg['1395']}}，{{b_lg['1396']}}"+"；{{b_lg['1397']}}，{{b_lg[1396]}}"-"。</p>
					<div class="center pad-t-20">
						<a class="btn bg-red9 fff pad-l-70 pad-r-70 pad-t-10 pad-b-10" @click="sure">{{b_lg[1008]}}</a>
					</div>
				</div>

				<div class="number-key">
					<ul class="cf f-24">
						<li @touchstart="numberk(1)"><span>1</span></li>
						<li @touchstart="numberk(2)"><span>2</span></li>
						<li @touchstart="numberk(3)"><span>3</span></li>
						<li @touchstart="numberk(4)"><span>4</span></li>
						<li @touchstart="numberk(5)"><span>5</span></li>
						<li @touchstart="numberk(6)"><span>6</span></li>
						<li @touchstart="numberk(7)"><span>7</span></li>
						<li @touchstart="numberk(8)"><span>8</span></li>
						<li @touchstart="numberk(9)"><span>9</span></li>
						<li @touchstart="numberk('C')"><span>C</span></li>
						<li @touchstart="numberk(0)"><span>0</span></li>
						<li @touchstart="numberk('d')"><span><img src="../images/w/del.png"></span></li>
					</ul>
				</div>

			</div>

		</div>

	</body>

	<script type="text/javascript">
		var app = null;
		var getCardID = localStorage.getItem("id");

		function cli_backpre() {
			app.backpre()
		}

		function fun1() {
			setlange_obj(); //加载头部语言包
			app = new Vue({
				el: "#app",
				data: {
					couponSn: "",
					msg: "",
					shop_name: "",
					shop_list_name: "",
					h: "", //是否适用本店铺
					status: "", //优惠券状态
					b_lg: global_lange, //语言包
					gold: "",
					balance: "",
					flag: 1,
					add: 1,
					point: "",
					amount: ""

				},
				created: function() {
					this.init();
				},
				methods: {
					init: function() {
						common_ajax(1, {
							id: getCardID
						}, "get_member_card_member_info", function(res) {
							app.point = res.result.info.point;
							app.amount = res.result.info.amount;
							app.gold = "";
							app.balance = "";
						})
					},
					numberk: function(e) { //按键
						var n = null;
						if(app.flag == 1) {
							n = app.gold;
						} else {
							n = app.balance;
						}
						switch(e) {
							case "d":
								n = n.substring(0, n.length - 1);
								break;
							case "C":
								n = "";
								break;
							default:
								n += e;
								break;
						}
						if(app.flag == 1) {
							app.gold = n;
						} else {
							app.balance = n;
						}
					},
					gotoart: function(e) {
						clicked(e);
					},
					sure: function() {
						var $th = this;
						if(app.gold == 0 && app.balance == 0) {
							var btnArray2 = [app.b_lg[1008]];
							mui.confirm(app.b_lg[1522], app.b_lg[1050], btnArray2, function(ee) {
								if(ee.index == 0) {
									//确定
									app.init();
								}
							}, "div")
						}
						var html = "";
						if(app.gold != 0) {
							if(app.add == 1) {
								html = app.b_lg[1523];
							} else {
								html = app.b_lg[1524];
							}
							html += app.gold;

						}
						if(app.balance != 0) {
							html += app.b_lg[1525] + app.gold;
						}
						if(html) { //当提示语不为空时弹出提示框
							var btnArray2 = [app.b_lg[1049], app.b_lg[1008]];
							mui.confirm(html, app.b_lg[1050], btnArray2, function(ee) {
								if(ee.index == 1) {
									//确定
									if(app.add == 2) {
										common_ajax(1, {
											card_id: getCardID,
											point: -app.gold,
											amount: -app.balance
										}, "set_member_card_amount", function(res) {
											if(res.status == 1) {
												$th.backpre();
											} else {
												mui.toast(res.msg);
											}

										})
									} else {
										common_ajax(1, {
											card_id: getCardID,
											point: app.gold,
											amount: -app.balance
										}, "set_member_card_amount", function(res) {
											if(res.status == 1) {
												$th.backpre();
											} else {
												mui.toast(res.msg);
											}

										})
									}

								}
							}, "div")
						}

					},
					scan: function() {
						//提示框
						var btnArray2 = [app.b_lg[1049], app.b_lg[1008]];
						mui.confirm(app.b_lg[1526], app.b_lg[1050], btnArray2, function(ee) {
							if(ee.index == 1) {
								//确定
								//跳转到扫码页
								setTimeout(function() {
									app.gotoart("../qrcode/qrscan.html?id=0&type=1");
								}, 300)
							} else {
								//取消
								app.init();
							}
						}, "div")
					},
					num: function(e) {
						var el = event.currentTarget
						el.classList.add('active')
						if(e == 1) {
							app.flag = 1
							el.parentNode.nextElementSibling.getElementsByTagName('div')[0].classList.remove("active")
						} else {
							app.flag = 2
							el.parentNode.previousElementSibling.getElementsByTagName('div')[0].classList.remove("active")

						}

					},
					alter: function() {
						if(app.add == 1) {
							app.add = 2;
						} else {
							app.add = 1;
						}
					},
					backpre: function() {
						if(isAPP) {
							var preUrl = plus.webview.currentWebview().opener();
							preUrl.evalJS("refresh()");
						}
						com_back();
					}

				}

			})
		}
	</script>

</html>
